package com.yonyou.cloud.member.domainmodel.dto;

import com.yonyou.cloud.member.domainmodel.vo.MemberId;
import com.yonyou.cloud.member.domainmodel.vo.TimeRange;
import com.yonyou.cloud.member.exceptions.ParameterException;
import com.yonyou.cloud.member.libs.util.NumberUtils;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;

@ApiModel(description = "会员积分变更明细查询条件")
public class MemberPointQueryConditionDto {
    @ApiModelProperty(value = "会员ID")
    @lombok.Setter
    private String memberId;
    @ApiModelProperty(value = "变更时间范围")
    @lombok.Setter
    private TimeRangeDto changeTime;
    @ApiModelProperty(value = "分页信息")
    @lombok.Getter
    @lombok.Setter
    private PageInfo pageInfo;

    /**
     * 转换为MemberId类型，ValueObject，不可变
     *
     * @return MemberId 会员ID
     */
    public MemberId getMemberId() {
        if (memberId == null || memberId.length() == 0) {
            throw new ParameterException("member_id_required", "请输入会员ID");
        }
        return new MemberId(NumberUtils.parseLong(memberId));
    }

    /**
     * 转换为TimeRange类型，ValueObject，不可变
     *
     * @return TimeRange 时间范围
     */
    public TimeRange getTimeRange() {
        if (this.changeTime == null) {
            throw new ParameterException("time_range_required", "请输入起止时间");
        }
        return this.changeTime.getTimeRange();
    }

    public void setMemberId(String memberId) {
        this.memberId = memberId;
    }

    public void setChangeTime(TimeRangeDto changeTime) {
        this.changeTime = changeTime;
    }
}